<?php

class Adept_Component_Label extends Adept_Component_Control 
{
    protected $errorClass = null;
    protected $errorStyle = null;
    protected $for;
    
    public function getErrorStyle() 
    {
        if (!is_null($this->errorStyle)) {
            return $this->errorStyle;
        }
        return $this->getValueOfBinding('errorStyle', $this->getStyle());
    }
    
    public function setErrorStyle($errorStyle) 
    {
        $this->errorStyle = $errorStyle;
    }
    
    public function getErrorClass() 
    {
        if (!is_null($this->errorClass)) {
            return $this->errorClass;
        }
        return $this->getValueOfBinding('errorClass', $this->getClass());
    }
    
    public function setErrorClass($errorClass) 
    {
        $this->errorClass = $errorClass;
    }

    public function getFor() 
    {
        if (!is_null($this->for)) {
            return $this->for;
        }
        return $this->getValueOfBinding('for', null);
    }
    
    public function isErrorMode()
    {
        if (($for = $this->getFor()) == null) {
            return false;
        }
        $forComponent = $this->getRoot()->findChildById($for);
    	if ($forComponent instanceof Adept_Component_ValueControl) {
    	    return !$forComponent->isValid();
    	} else {
    	    return false;
    	}
    }
    
    public function setFor($for) 
    {
        $this->for = $for;
    }
    
    public function hasRenderer() 
    {
    	return true;
    }	
    
}